import { http } from '@/utils/http'

// 获取频道列表
export function getChannelApi() {
  return http({
    url: 'channels',
    method: 'GET'
  })
}

// 提交文章表单
export function createArticleApi(data) {
  return http({
    url: '/mp/articles?draft=false',
    method: 'POST',
    data
  })
}

// 获取文章列表
export function getArticlesApi(params) {
  return http({
    url: '/mp/articles',
    method: 'GET',
    params
  })
}

// 删除文章
export function removeArticlesApi(id) {
  return http({
    url: '/mp/articles/' + id,
    method: 'DELETE',
  })
}

// 根据ID获取文章详情
export function getArticleByIdApi(id) {
  return http({
    url: '/mp/articles/' + id,
    method: 'GET',
  })
}

// 编辑文章
export function editArticleByIdApi(data, id) {
  return http({
    url: '/mp/articles/' + id,
    method: 'PUT',
    data
  })
}